package com.jeecg.study.action.impl;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jeecg.study.action.ActionNew;
import com.jeecg.study.common.utils.Global;
import com.jeecg.study.entity.MessageVo;
import com.jeecg.study.entity.UserForm;
import com.jeecg.study.form.ActionForm;
/**
 * @see 登录请求的action
 * @author wuhn
 * @date 2018年5月1日 15:59:23
 */
public class LoginAction implements ActionNew {

	@Override
	public String execute(HttpServletRequest request, HttpServletResponse response,
										ActionForm actionForm,Map<String, String> mapping) {
		MessageVo messageVo =new MessageVo();
		UserForm userForm=(UserForm)actionForm;
		messageVo.setUserName(userForm.getUserName());
		if("admin".equals(userForm.getUserName()) && "123".equals(userForm.getPassword())){
			messageVo.setResult("登录成功!");
			request.setAttribute("messageVo", messageVo);
			return mapping.get(Global.RESULT_SUCCESS);
		}
		messageVo.setResult("登录失败!");
		request.setAttribute("messageVo", messageVo);
		return mapping.get(Global.RESULT_FAIL);
	}

}
